home *** CD-ROM | disk | FTP | other *** search
/ Harry's Story Disc & Coloring Book / Harry's Story Disc & Coloring Book.iso / mac / TITLE.MST < prev    next >
Text File  |  1993-09-29  |  12KB  |  389 lines

  1. '**************************************************************************
  2. '*
  3. '* Viewer Runtime Setup Script
  4. '*
  5. '**************************************************************************
  6.  
  7.     '' Global variables
  8.     GLOBAL TitleShortName$
  9.     GLOBAL TitleLongName$
  10.     GLOBAL MVBFileName$
  11.     GLOBAL PromptForPath%
  12.     GLOBAL DefaultPath$
  13.     GLOBAL ProgManGroup$
  14.     GLOBAL ProgManItem$
  15.  
  16.     '' If you are doing a simple Setup, then you should be able to set the 
  17.     '' following variables and be ready to run. If you are setting up more than 
  18.     '' one MVB file, or if you have a help file or custom DLLs, please see the
  19.     '' ModifyViewerIni subroutine. If you have more than one program manager
  20.     '' icon, please see the ModifyProgramManager subroutine. If you have any
  21.     '' custom fonts, please see the RegisterCustomFonts subroutine.    
  22.     
  23.     '' Set the following string to a short form of the title name
  24.     
  25.     TitleShortName$ = "StoryDisc"
  26.     
  27.     '' Set the following string to a long form of the title name
  28.     
  29.     TitleLongName$ = "Harry's StoryDisc and Coloring Book"
  30.         
  31.     '' Set the following variable to the name of the MVB file, without the extension
  32.         
  33.     MVBFileName$ = "children"
  34.         
  35.     '' Set the following variable to 1 if Setup is to prompt for a directory for any
  36.     '' title files that need to get installed onto the hard disk. Note that you must
  37.     '' list these files in the [Installed Title Files] section of TITLE.INF. If you 
  38.     '' specify 0 then any such files will be copied to the Windows directory. You might
  39.     '' do this if you only want to copy an icon file or so.
  40.         
  41.     PromptForPath% = 0
  42.         
  43.     '' If you have specified 1 in PromptForPath%, set the following variable to the 
  44.     '' default path that will be displayed in the dialog.
  45.         
  46.     DefaultPath$ = ""
  47.     
  48.     '' Set the following variable to the name of the program manager group you would like to create.
  49.         
  50.     ProgManGroup$ = "Harry's StoryDisc"
  51.     
  52.     '' Set the following variable to the name of the program manager icon for your title
  53.         
  54.     ProgManItem$ = "StoryDisc"
  55.     
  56.     '*************************************************************************
  57.     '** Mainline
  58.     '*************************************************************************
  59.  
  60.     GLOBAL CUIDLL$
  61.  
  62.     '' Include files
  63.     '$INCLUDE 'setupapi.inc'
  64.     
  65.     '' Custom UI dll
  66.     CUIDLL$ = "mscuistf.dll"
  67.     
  68.     '' Dialog ID's
  69.     CONST DESTPATH      = 1000
  70.     CONST APPHELP       = 2000
  71.     CONST TOOBIG        = 3000
  72.     CONST BADPATH       = 4000
  73.     CONST SUCCESS       = 5000
  74.     
  75.     '' Bitmap ID
  76.     CONST LOGO = 1
  77.     
  78.     '' Functions and subroutines
  79.     DECLARE FUNCTION AddFont LIB "mscuistf.dll" (szFont$, szName$) AS INTEGER
  80.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  81.     DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  82.     DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
  83.     DECLARE SUB RegisterFont(fontfile$, fontname$)
  84.     DECLARE SUB ModifyViewerIni
  85.     DECLARE SUB RegisterCustomFonts
  86.     DECLARE SUB ModifyProgramManager
  87.     DECLARE SUB ShowSuccess
  88.     
  89.     '' The following statement turns size checking off. Set it to scmOnFatal to enable
  90.     '' size checking, where Setup will compare the disk file size with the INF file size
  91.     '' and report an error if they are not the same.
  92.     
  93.     i% = SetSizeCheckMode(scmOff)
  94.     
  95.     '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to alter the banner bitmap.
  96.     
  97.     SetTitle "Harry's StoryDisc Setup"
  98.     SetBitmap CUIDLL$, LOGO 
  99.     
  100.     '' Read in the INF file.
  101.     
  102.     ReadInfFile GetSymbolValue("STF_CWDDIR") + "TITLE.INF"
  103.     
  104.     '' Decide where to put title files
  105.     IF PromptForPath% = 1 THEN
  106.         szTitleDir$ = GetTitleDir(DefaultPath$)
  107.         IF szTitleDir$ = "" THEN
  108.             GOTO QUIT
  109.         ENDIF
  110.     ELSE
  111.         szTitleDir$ = GetWindowsDir()
  112.     ENDIF    
  113.     
  114.     '' Copy files
  115.     IF CopyFiles(szTitleDir$) = 0 THEN
  116.         GOTO QUIT
  117.     ENDIF
  118.  
  119.     '' Create the MVIEWER2.EXE MVB association 
  120.     CreateIniKeyValue "WIN.INI", "Extensions", "MVB", "mviewer2.exe", cmoNone
  121.  
  122.     '' Register in VIEWER.INI
  123.     ModifyViewerIni
  124.  
  125.     '' Register custom fonts
  126.     RegisterCustomFonts
  127.     
  128.     '' Modify Program Manager
  129.     ModifyProgramManager    
  130.     
  131.     '' Success dialog
  132.     ShowSuccess
  133.     
  134.     '' Now start the title
  135.  
  136.     RUN "mviewer2.exe " + MVBFileName$ + ".MVB", NOWAIT
  137.  
  138. QUIT:
  139.     
  140.     END
  141.     
  142.  
  143. '*************************************************************************
  144. '** Purpose:
  145. '**     Prompts the user for a path for the title files
  146. '** Arguments:
  147. '**     szDefault$ - default path
  148. '** Returns:
  149. '**     New valid path name, or "" if the user quit.
  150. '*************************************************************************
  151.  
  152. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  153.  
  154.     SetSymbolValue "String", TitleShortName$
  155.     SetSymbolValue "EditTextIn", szDefault$
  156.     SetSymbolValue "EditFocus", "ALL"
  157.  
  158.     GETPATH:
  159.  
  160.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  161.  
  162.     IF sz$ = "CONTINUE" THEN
  163.         szTitleDir$ = GetSymbolValue("EditTextOut")
  164.         IF IsDirWritable(szTitleDir$) = 0 THEN
  165.  
  166.             BADPATH:
  167.  
  168.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  169.             IF sz$ = "REACTIVATE" THEN
  170.                 GOTO BADPATH
  171.             END IF
  172.             UIPop 1
  173.             GOTO GETPATH
  174.         END IF
  175.         UIPop 1
  176.         CreateDir szTitleDir$, cmoNone
  177.  
  178.     ELSEIF sz$ = "REACTIVATE" THEN
  179.         GOTO GETPATH
  180.  
  181.     ELSE
  182.         szTitleDir$ = ""
  183.  
  184.     END IF
  185.  
  186.     GetTitleDir = szTitleDir$
  187.  
  188. END FUNCTION
  189.  
  190.  
  191. '*************************************************************************
  192. '** Purpose:
  193. '**     Copies the files in the INF file
  194. '** Arguments:
  195. '**     szTitleDir$ - destination directory for the title files
  196. '** Returns
  197. '**     1 if files were copied, 0 otherwise
  198. '*************************************************************************
  199.  
  200. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  201.  
  202.     '' Add all system files to the copy list
  203.     AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
  204.     
  205.     '' Add all of the title files to the copy list
  206.     AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
  207.     
  208.     '' Check size
  209.     szExtras$ = "Extra"
  210.     szCosts$ = "Costs"
  211.     szNeededs$ = "Neededs"
  212.     FOR i% = 1 TO 26 STEP 1
  213.         AddListItem szExtras$, "0"
  214.     NEXT i%
  215.     
  216.     '' We assume that VIEWER.INI will take another 4K
  217.     ReplaceListItem szExtras$, ASC(MID$(GetWindowsDir(), 1, 1)) - ASC("A") + 1, STR$(4096)
  218.     
  219.     '' Get amount of space required
  220.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  221.     
  222.     '' Put up a message if there is not enough space
  223.     FOR i% = 1 TO 26 STEP 1
  224.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  225.     
  226.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  227.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  228.     
  229.             TOOBIG:
  230.     
  231.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  232.             IF sz$ = "REACTIVATE" THEN
  233.                 GOTO TOOBIG
  234.             END IF
  235.             UIPop 1
  236.             CopyFiles = 0
  237.             GOTO DONTCOPY
  238.         END IF
  239.     NEXT i%
  240.     
  241.     '' Copy the files
  242.     CopyFilesInCopyList
  243.     
  244.     CopyFiles = 1
  245.  
  246. DONTCOPY:
  247.  
  248. END FUNCTION
  249.  
  250.  
  251. '*************************************************************************
  252. '** Purpose:
  253. '**     Puts up a success dialog
  254. '*************************************************************************
  255.  
  256. SUB ShowSuccess STATIC
  257.  
  258.     SUCCESS:
  259.     
  260.     SetSymbolValue "String1", TitleShortName$
  261.     sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  262.     IF sz$ = "REACTIVATE" THEN
  263.         GOTO SUCCESS
  264.     END IF
  265.     UIPop 1
  266.     
  267. END SUB
  268.  
  269.  
  270. '*************************************************************************
  271. '** Purpose:
  272. '**     Appends a file name to the end of a directory path,
  273. '**     inserting a backslash character as needed.
  274. '** Arguments:
  275. '**     szDir$  - full directory path (with optional ending "\")
  276. '**     szFile$ - filename to append to directory
  277. '** Returns:
  278. '**     Resulting fully qualified path name.
  279. '*************************************************************************
  280.  
  281. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  282.     IF szDir$ = "" THEN
  283.         MakePath = szFile$
  284.     ELSEIF szFile$ = "" THEN
  285.         MakePath = szDir$
  286.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  287.         MakePath = szDir$ + szFile$
  288.     ELSE
  289.         MakePath = szDir$ + "\" + szFile$
  290.     END IF
  291. END FUNCTION
  292.  
  293.  
  294. '*************************************************************************
  295. '** Purpose:
  296. '**     Registers a font.
  297. '** Arguments:
  298. '**     fontfile$ - font filename
  299. '**     fontname$ - font name.
  300. '*************************************************************************
  301.  
  302. SUB RegisterFont(fontfile$, fontname$) STATIC
  303.  
  304.     '' A simple error catching wrapper around AddFont, which is a 'C' routine in MSCUISTF.DLL
  305.  
  306.     IF AddFont(fontfile$, fontname$) = 0 THEN
  307.         j% = DoMsgBox("Could not install " + fullfontfile$ + " font.", "Viewer Font Installation", 0)
  308.     ENDIF
  309.  
  310. END SUB
  311.  
  312.  
  313. '*************************************************************************
  314. '** Purpose:
  315. '**     Registers title in VIEWER.INI
  316. '*************************************************************************
  317.  
  318. SUB ModifyViewerIni STATIC
  319.  
  320.     '' Get the VIEWER.INI file
  321.     
  322.     szIni$ = MakePath(GetWindowsDir(), "VIEWER.INI")
  323.  
  324.     '' First register the title file, setting the Name and Path entries. We assume that the
  325.     '' MVB file is the same directory as SETUP.EXE.
  326.     
  327.     CreateIniKeyValue szIni$, MVBFileName$, "Name", TitleLongName$, cmoOverwrite
  328.     CreateIniKeyValue szIni$, MVBFileName$, "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
  329.     
  330.     CreateIniKeyValue szIni$, "vwrhelp", "Name", "Harry's StoryDisc Help", cmoOverwrite
  331.     CreateIniKeyValue szIni$, "vwrhelp", "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
  332.  
  333.  
  334.     '' If you are installing any other MVB files then you would want to add extra Name and Path
  335.     '' entries for each here.
  336.  
  337.     '' Now we have to register the MVB file in the [FILES] section, so that Viewer can find
  338.     '' files that are not on the path and display a special message when a file is not found.
  339.  
  340.     CreateIniKeyValue szIni$, "FILES", MVBFileName$ + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  341.  
  342.     CreateIniKeyValue szIni$, "FILES", "vwrhelp" + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  343.  
  344.     '' You would want to add similar entries here if you are including a help file or any custom DLLs.    
  345.  
  346. END SUB
  347.  
  348.  
  349. '*************************************************************************
  350. '** Purpose:
  351. '**     Creates program manager entries for the title
  352. '*************************************************************************
  353.  
  354. SUB ModifyProgramManager STATIC
  355.  
  356.     '' Create the program manager group
  357.  
  358.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  359.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  360.     
  361.     '' Create an entry for the title
  362.      
  363.     CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), "harry.ico", cmoOverwrite
  364.     
  365.     '' Add other program manager groups as required here. Note that the 4th parameter in the above line
  366.     '' can be set to an icon file to customize the icon. 
  367.  
  368. END SUB
  369.  
  370.  
  371. '*************************************************************************
  372. '** Purpose:
  373. '**     Registers custom fonts with Windows.
  374. '*************************************************************************
  375.  
  376. SUB RegisterCustomFonts STATIC
  377.  
  378.     '' If you install custom fonts, then you will want to add lines here of the following
  379.     '' form in order to register them with the current Windows session and to add them to
  380.     '' the WIN.INI fonts section. Note that TrueType fonts can only be installed on a Win 3.1
  381.     '' machine - RegisterFont automatically creates the required .FOT file for TrueType fonts.
  382.     ''    
  383.     ''      RegisterFont mistral.ttf, "Mistral (TrueType)"
  384.     ''
  385.  
  386. END SUB
  387.  
  388.  
  389.